using System;
public class BaseProperty
{
    /// <summary>
    /// 最大生命值
    /// </summary>
    public int Health;
    /// <summary>
    /// 最大精神值
    /// </summary>
    public int Sprite;
    /// <summary>
    /// 攻击力
    /// </summary>
    public int Attack;
    /// <summary>
    /// 防御力
    /// </summary>
    public int Defense;
    /// <summary>
    /// 速度
    /// </summary>
    public int Speed;
    /// <summary>
    /// 行动力
    /// </summary>
    public int Movement;
    /// <summary>
    /// 命中
    /// </summary>
    public int HitRate;

    /// <summary>
    /// 最大生命值百分比 0.01 = 1%
    /// </summary>
    public float HealthPercent;
    /// <summary>
    /// 最大精神值百分比 0.01 = 1%
    /// </summary>
    public float SpritePercent;
    /// <summary>
    /// 攻击力百分比 0.01 = 1%
    /// </summary>
    public float AttackPercent;
    /// <summary>
    /// 防御力百分比 0.01 = 1%
    /// </summary>
    public float DefensePercent;
    /// <summary>
    /// 速度百分比 0.01 = 1%
    /// </summary>
    public float SpeedPercent;
    /// <summary>
    /// 行动力百分比 0.01 = 1%
    /// </summary>
    public float MovementPercent;

    public int FinalHitRate;

    public float FinalDamageBonus;

    public float FinalDamageReduction;

    public int MustHit;

    public int MustDodge;


    public static BaseProperty operator +(BaseProperty a, BaseProperty b)
    {
        BaseProperty result = new();
        Type t = a.GetType();
        var p = t.GetProperties();
        foreach (var item in p)
        {
            var v1 = item.GetValue(a);
            var v2 = item.GetValue(b);
            Type t1 = v1.GetType();
            if (t1 == typeof(int))
            {
                item.SetValue(result, (int)v1 + (int)v2);
            }
            else if (t1 == typeof(float))
            {
                item.SetValue(result, (float)v1 + (float)v2);
            }
        }
        var fs = result.GetType().GetFields();
        foreach (var f in fs)
        {
            var v1 = f.GetValue(a);
            var v2 = f.GetValue(b);
            Type t2 = v1.GetType();
            if (t2 == typeof(int))
            {
                f.SetValue(result, (int)v1 + (int)v2);
            }
            else if (t2 == typeof(float))
            {
                f.SetValue(result, (float)v1 + (float)v2);
            }
        }
        return result;
    }

    public static BaseProperty operator -(BaseProperty a, BaseProperty b)
    {
        BaseProperty result = new BaseProperty();
        Type t = a.GetType();
        var p = t.GetProperties();
        foreach (var item in p)
        {
            var v1 = item.GetValue(a);
            var v2 = item.GetValue(b);
            Type t1 = v1.GetType();
            if (t1 == typeof(int))
            {
                item.SetValue(result, (int)v1 - (int)v2);

            }
            else if (t1 == typeof(float))
            {
                item.SetValue(result, (float)v1 - (float)v2);
            }
        }
        return result;
    }

    public static BaseProperty operator *(BaseProperty a, float b)
    {
        BaseProperty result = new BaseProperty();
        Type t = a.GetType();
        var p = t.GetProperties();
        foreach (var item in p)
        {
            var v1 = item.GetValue(a);
            Type t1 = v1.GetType();
            if (t1 == typeof(int))
            {
                item.SetValue(result, (int)v1 * b);

            }
            else if (t1 == typeof(float))
            {
                item.SetValue(result, (float)v1 * b);
            }
        }
        return result;
    }

    public static BaseProperty operator /(float a, BaseProperty b)
    {
        BaseProperty result = new BaseProperty();
        Type t = b.GetType();
        var p = t.GetProperties();
        foreach (var item in p)
        {
            var v1 = item.GetValue(b);
            Type t1 = v1.GetType();
            if (t1 == typeof(int))
            {
                item.SetValue(result, a / (int)v1);

            }
            else if (t1 == typeof(float))
            {
                item.SetValue(result, a / (float)v1);
            }
        }
        return result;
    }

}